<!doctype html>
<html>

<head>
  <meta charset='utf-8'>
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width">
  <title>Cycle.js - API reference (rxjs-run)</title>

  <!-- Flatdoc -->
  <script src='../support/vendor/jquery.js'></script>
  <script src='../support/vendor/highlight.pack.js'></script>
  <script src='../legacy.js'></script>
  <script src='../flatdoc.js'></script>

  <!-- Algolia's DocSearch main theme -->
  <link href='//cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css' rel='stylesheet' />

  <!-- Others -->
  <script async src="//static.jsbin.com/js/embed.js"></script>

  <!-- Flatdoc theme -->
  <link href='../theme/style.css' rel='stylesheet'>
  <script src='../theme/script.js'></script>
  <link href='../support/vendor/highlight-github-gist.css' rel='stylesheet'>

  <!-- Meta -->
  <meta content="Cycle.js - API reference (rxjs-run)" property="og:title">
  <meta content="A functional and reactive JavaScript framework for predictable code" name="description">

  <!-- Content -->
  <script id="markdown" type="text/markdown" src="index.html">
# Run() for RxJS - [source](https://github.com/cyclejs/cyclejs/tree/master/rxjs-run)

Cycle.js `run(main, drivers)` function for applications written with RxJS version **5**.

```
npm install @cycle/rxjs-run rxjs
```

**Note: `rxjs` package is required too.**

## Basic usage

```js
import run from '@cycle/rxjs-run'

run(main, drivers)
```

# API

## <a id="run"></a> `run(main, drivers)`

Takes a `main` function and circularly connects it to the given collection
of driver functions.

**Example:**
```js
import run from '@cycle/rxjs-run';
const dispose = run(main, drivers);
// ...
dispose();
```

The `main` function expects a collection of "source" Observables (returned
from drivers) as input, and should return a collection of "sink" Observables
(to be given to drivers). A "collection of Observables" is a JavaScript
object where keys match the driver names registered by the `drivers` object,
and values are the Observables. Refer to the documentation of each driver to
see more details on what types of sources it outputs and sinks it receives.

#### Arguments:

- `main: Function` a function that takes `sources` as input and outputs a collection of `sinks` Observables.
- `drivers: Object` an object where keys are driver names and values are driver functions.

#### Returns:

*(Function)* a dispose function, used to terminate the execution of the Cycle.js program, cleaning up resources used.

## <a id="setup"></a> `setup(main, drivers)`

A function that prepares the Cycle application to be executed. Takes a `main`
function and prepares to circularly connects it to the given collection of
driver functions. As an output, `setup()` returns an object with three
properties: `sources`, `sinks` and `run`. Only when `run()` is called will
the application actually execute. Refer to the documentation of `run()` for
more details.

**Example:**
```js
import {setup} from '@cycle/rxjs-run';
const {sources, sinks, run} = setup(main, drivers);
// ...
const dispose = run(); // Executes the application
// ...
dispose();
```

#### Arguments:

- `main: Function` a function that takes `sources` as input and outputs a collection of `sinks` Observables.
- `drivers: Object` an object where keys are driver names and values are driver functions.

#### Returns:

*(Object)* an object with three properties: `sources`, `sinks` and `run`. `sources` is the collection of driver sources, `sinks` is the
collection of driver sinks, these can be used for debugging or testing. `run`
is the function that once called will execute the application.


  </script>

  <!-- Initializer -->
  <script>
    Flatdoc.run({
      fetcher: function (callback) {
        callback(null, document.getElementById('markdown').innerHTML);
      },
      highlight: function (code, value) {
        return hljs.highlight(value, code).value;
      },
    });
  </script>

</head>

<body role='flatdoc' class="no-literate">

  

  <div class='header'>
    <div class='left'>
      <h1><a href="/"><img class="logo" src="../img/cyclejs_logo.svg">Cycle.js</a></h1>
      <ul>
        <li><a href='../getting-started.html'>Guide</a></li>
        <li><a href='../api/index.html'>API</a></li>
        <li><a href='../releases.html'>Releases</a></li>
        <li><a href='https://github.com/cyclejs/cyclejs'>GitHub</a></li>
      </ul>
      <input id="docsearch" />
    </div>
    <div class='right'>
      <!-- GitHub buttons: see https://ghbtns.com -->
      <iframe src="https://ghbtns.com/github-btn.html?user=cyclejs&amp;repo=cyclejs&amp;type=watch&amp;count=true"
        allowtransparency="true" frameborder="0" scrolling="0" width="110" height="20"></iframe>
    </div>
  </div>

  <div class='content-root'>
    <div class='menubar'>
      <div class='menu section'>
        
        <div role='flatdoc-menu'></div>
        
      </div>
    </div>
    <div role='flatdoc-content' class='content'></div>
    
  </div>
  

  <script>
    ((window.gitter = {}).chat = {}).options = {
      room: 'cyclejs/cyclejs'
    };
  </script>
  <script src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer></script>
  <script src='//cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js'></script>
  <script src='../docsearch.js'></script>
</body>

</html>
